function addformpricefull()
{

   
    $("#firstaddform").append('<div id="feature'+rowdiv+'" class="itPlg featureclass">'+dataform['pricefull']+"</div>");
    var rownow=rowdiv;

    $('#feature'+rownow+' button[name="btnadd"]').click(function() {
    
    var addstock=$('#feature'+rownow+' input[name="addstock[]"]').val();
    
    var intstock=parseInt(addstock,10);
    
    
    var inventdata=parseInt($('#feature'+rownow+' .inventtext').html(),10);
    
    var sumall=0;
  
          sumall=intstock+inventdata;
    
 
    
    
    
    
    $('#feature'+rownow+' .inventtext').html(sumall);
    
    
    
    
    });
    
    
    $('#feature'+rownow+' button[name="btnremove"]').click(function() {
    
    var addstock=$('#feature'+rownow+' input[name="removestock[]"]').val();
    
    var intstock=parseInt(addstock,10);
    
    
    var inventdata=parseInt($('#feature'+rownow+' .inventtext').html(),10);
    
    var sumall=0;
  
          sumall=inventdata-intstock;
    
    
    
          if(sumall<0)
          {
          sumall=0;
          
          }
    
    
    
    
    $('#feature'+rownow+' .inventtext').html(sumall);
    
    
    
    
    });
    
    
    
    
    
    rowdiv++;

}
function saveformpricefull(id,plugid)
{
var obj={};
var cart=$("#"+id+' input[name="cart[]"]:checked').val();
var attr=$("#"+id+' input[name="attr[]"]:checked').val();

  if($("#"+id+' input[name="price[]"]').val()=='')
  {
  obj={'code':'22','msg':'Requied Price','error':1};
  return obj;
  }
  var userpoint=0;
  var point=0;
  var price=$("#"+id+' input[name="price[]"]').val();
  var realprice;
  realprice=price;
  
  
  if($("#"+id+' input[name="userpoint[]"]:checked').val())
  {
  userpoint=$("#"+id+' input[name="userpoint[]"]:checked').val();
  
  
  if($("#"+id+' input[name="point[]"]').val()=='')
  {
  obj={'code':'22','msg':'Requied Point','error':1};
  return obj;
  }
  point=$("#"+id+' input[name="point[]"]').val();
  
  }
  var usersale=0;
  var statusesale=0;
  var saleprice=0;
  var salediscount=0;
  var statusdiscount=0;
  if($("#"+id+' input[name="usersale[]"]:checked').val())
  {
  usersale=$("#"+id+' input[name="usersale[]"]:checked').val();
  

  if($("#"+id+' input[name="statusesale[]"]:checked').val()=='1')
  {
  statusesale=$("#"+id+' input[name="statusesale[]"]:checked').val();
  
  
  if($("#"+id+' input[name="saleprice[]"]').val()=='')
  {
      obj={'code':'22','msg':'Requied Sale Price','error':1};
    return obj;
  
  }else
  {
  saleprice=$("#"+id+' input[name="saleprice[]"]').val();
  realprice=saleprice;
  
  }
  
  
  }
  else if($("#"+id+' input[name="statusesale[]"]:checked').val()=='2')
  {
  statusesale=$("#"+id+' input[name="statusesale[]"]:checked').val();
  
  
    if($("#"+id+' input[name="salediscount[]"]').val()=='')
  {
      obj={'code':'22','msg':'Requied Sale Discount','error':1};
    return obj;
  
  }else
  {
  salediscount=$("#"+id+' input[name="salediscount[]"]').val();
  
  
  }
  
  
  statusdiscount=$("#"+id+' select[name="statusdiscount[]"]').val();
  
  if(statusdiscount=='1')
  {
  realprice=parseFloat(price)-parseFloat(salediscount);
  
  }else
  {
  
  var discountprice=parseInt((parseInt(price)*10)/100);
  
  realprice=parseInt(price,10)-discountprice;
  
  
  }
  
  
  
  
  }  
  else
  {
  
    obj={'code':'22','msg':'Choose Condition Sale Price','error':1};
    return obj;
  
  }
  
  
  
  
  
  
  }
  
  var unlimit=0;
  var amount=0;
  if($("#"+id+' input[name="unlimit[]"]:checked').val())
  {
    
    unlimit=$("#"+id+' input[name="unlimit[]"]:checked').val();
    
    
    }else
    {
    
    amount=$("#"+id+' .inventtext').html();
    
    }
  
  
  
  obj={
  plugid:plugid,
  price:price,
  cart:cart,
  userpoint:userpoint,
  point:point,
  usersale:usersale,
  statusesale:statusesale,
  saleprice:saleprice,
  salediscount:salediscount,
  statusdiscount:statusdiscount,
  unlimit:unlimit,
  amount:amount,
  realprice:realprice,
  attr:attr
  
  
  
  };

    return obj;



}
function add2cart(productid)
{
var qtynum=$('#main-middle input[name="qty"]').val();
 loaddata();
$.post(serviceinfo+'add2cart', { productid:productid,qty:qtynum }, function(data) { 

  loadclosedata();
     if(data.error.response)
        {
        if(data.error.error[0].code==5)
        {
        $('.ovlPopLd').hide();
        $('.wrpPopLI').fadeIn();

        //console.log('test');
        }else
        {
        //alertbox(data.error.error);

        alertbox(data.error.error);
        }

        }
     else
     {
     if(data.data)
     {
     $('#cartlinkbtn').html('Cart('+data.data+')');
     }
     

    }



});

}
function getformpricefull(dataplugin)
{
var arraydata=dataplugin;
var code  = '<div class="ldIt wrpOutNewPrcLd clBg4">'+"\n";
code += '<div class="wrpInNewPrcLd">'+"\n";
code += '<div class="hdNewPrcLd clTxt2 fs04">'+"\n";
code += '<span class="boldGen">Order</span>'+"\n";
code += '</div>'+"\n";
code += '<div class="bdNewPrcLd">'+"\n";
code += '<div class="newPrc wrpNewPrcLd clearfix">'+"\n";
code += '<h2 class="clTxt2 fs04">Regular Price</h2>'+"\n";
if(arraydata['realprice']==arraydata['price'])
{
code += '<span class="newPrcLd">'+arraydata['price']+' THB</span>'+"\n";
}else
{
code += '<span class="newPrcLd mdl">'+arraydata['price']+' THB</span>'+"\n";

}
code += '</div>'+"\n";

if(arraydata['realprice']!=arraydata['price'])
{
code += '<div class="newPrc wrpSalePrc clearfix">'+"\n";
code += '<h2 class="clTxt2 fs04">Sale Price</h2>'+"\n";
code += '<span class="newPrcLd">'+arraydata['realprice']+' THB</span>'+"\n";
code += '</div>'+"\n";
}

if(arraydata['cart']=='1')
{

code += '<div class="newPrc wrpQtyPrc clearfix">'+"\n";
code += '<h2 class="clTxt2 fs04">Quantity</h2>'+"\n";
code += '<input type="text" name="qty" value="1" class="clBg5 clBd2 fs03 clTxt2">'+"\n";


code += '<button type="button" onclick="add2cart('+arraydata['productid']+')" class="btnAddToCart clTxtW clBgBt1 fs04">Add to Cart</button>'+"\n";


if(arraydata['amount']=='0'&&arraydata['unlimit']=='0')
{
code += '<span class="notEnouLd clErrTxt">Product is not enough.</span>'+"\n";
}
//code += '<span class="notEnouLd clErrTxt">Product is not enough.</span>'+"\n";

code += '</div>'+"\n";

}

code += '<div class="newPrc wrpQtyPrc clearfix">'+"\n";

if(arraydata['amount']=='0'&&arraydata['unlimit']=='0')
{
code += '<h2 class="fs04 boldGen clErrTxt">Out of Stock</h2>'+"\n";
}

code += '</div>'+"\n";
code += '</div>'+"\n";
code += '</div>'+"\n";
code += '</div>';
return code;

}
function editformpricefull(datarow)
{
              addformpricefull();
              var rownow= rowdiv-1;
              
              $('#feature'+rownow+' input[name="price[]"]').val(datarow.price);
              
              $('#feature'+rownow+' input[name="cart[]"]').filter('[value='+datarow.cart+']').prop('checked', true);
              $('#feature'+rownow+' input[name="attr[]"]').filter('[value='+datarow.attr+']').prop('checked', true);
              $('#feature'+rownow+' input[name="userpoint[]"]').filter('[value='+datarow.userpoint+']').prop('checked', true);
              
              $('#feature'+rownow+' input[name="point[]"]').val(datarow.point);
              
              $('#feature'+rownow+' input[name="usersale[]"]').filter('[value='+datarow.usersale+']').prop('checked', true);
              
              $('#feature'+rownow+' input[name="statusesale[]"]').filter('[value='+datarow.statusesale+']').prop('checked', true);
              
              $('#feature'+rownow+' input[name="saleprice[]"]').val(datarow.saleprice);
              $('#feature'+rownow+' input[name="salediscount[]"]').val(datarow.salediscount);
              
              
              
               $('#feature'+rownow+' select[name="statusdiscount[]"]').val(datarow.statusdiscount);
               
               
               $('#feature'+rownow+' input[name="unlimit[]"]').filter('[value='+datarow.unlimit+']').prop('checked', true);
               
               $('#feature'+rownow+' .inventtext').html(datarow.amount);
               
               
              
              //
//              if(datarow.price!='0.00')$('#feature'+rownow+' input[name="price[]"]').val(datarow.price);
//              if(datarow.saleprice!='0.00')$('#feature'+rownow+' input[name="saleprice[]"]').val(datarow.saleprice);
//              
//              $('#feature'+rownow+' select[name="curid[]"]').val(datarow.curid);

}